<template>
	<view @click.stop="() => {}" v-if="judgeGopayOrQianyue()">
		<view
			:class="{ actionBtn: true, actionBtn0: position == 0, actionBtn1: position == 1, actionBtn2: position == 2, actionBtn3: position == 3 }"
			@click.stop="payHandler">
			{{ btnTxt }}
		</view>
		<PartyCover @partCoverCall="partCoverCall" ref="partCover" />

		<!-- 微信环境中提示点击右上角在浏览器中打开 -->
		<view class="bigMengceng" @click="closeMengceng" v-if="isWexinOpenSecondSign">
			<image class="openImg" src="./open.png" mode="aspectFit"></image>
		</view>


		<u-modal v-model="zfuLoginWinSta" content="当前账号未支付宝登录授权,请先登录授权!" @confirm="confirmZfbLogin"
			@cancel="cancelZfbLogin" show-cancel-button cancel-text="取消" confirm-text="去授权"></u-modal>
	</view>
</template>

<script>
	// 去支付 & 确认支付 按钮
	import {
		checkPosition,
		checkOrderSettleNeedPay,
		notifyTopPageRefresh
	} from '../utils/checkShowBtn.js';
	import {
		go_Myl,
		go_EQian,
		getUserId,
		getWxCodeOpenId,
		getZfbUserIdSta,
		saveUserId,
		saveZWZUserDetail,
		getZWZUserDetail
	} from '../../../../utils/index.js';
	import {
		getAppId,
		tradePay
	} from '../../../../utils/platform';
	import PartyCover from '../../../partyCover';
	import {
		APP_APPID
	} from '../../../../utils/constant.js';
	import {
		SHA512
	} from 'crypto-js';

	export default {
		name: 'quzhifu',
		components: {
			PartyCover
		},
		props: {
			order: {
				type: Object,
				default: {}
			}, // 订单对象
			isUsedInList: {
				type: Boolean,
				default: true
			}, // 是否使用在订单列表页面
			userOrderCashDto: {
				type: Object,
				default: null
			}
		},
		data() {
			return {
				zfuLoginWinSta: false,
				appLoginAppidStr: '',
				isHasUserIdSta: false, //判断当前用户是否有userId（默认没有）
				isWexinOpenSecondSign: false,
				wxOpenId: '',
				isWxBrowser: false, //是否在微信浏览器中
				code: '',
				// signValiSta:
				isSignValidate: '2',
				userId: '',
				zfbHasPayment: true,
				wxHasPayment: true,
				mengcengShow: false,
				tankuangShow: false,
				zhifubaoCheckedState: false,
				weixinCheckedState: false,
				uniPlatform: '',
				// #ifdef MP-ALIPAY
				payType: 'alipays',
				// #endif
				// #ifdef MP-WEIXIN
				payType: 'wechat',
				// #endif
				// #ifndef MP
				payType: '',
				// #endif
			};
		},

		computed: {
			position: function() {
				return checkPosition.quzhifu(this.order, this.isUsedInList);
			},
			btnTxt: function() {
				// contractVerify: 1：下单默认，2：付合同费，3/4：正在生成合同，5：签合同，7：现在签署代扣
				if (this.order.contractVerify == 2) {
					return '付签约费'
				}
				if (this.order.contractVerify == 3 || this.order.contractVerify == 4) {
					return '合同生成中'
				}
				if (this.order.contractVerify == 5) {
					return '签合同'
				}
				if (this.order.contractVerify == 7 || this.order.contractVerify == 8) {
					return '签代扣'
				}
			}
		},
		watch: {
			isSignValidate(newValue, oldValue) {
				console.log('==newValue=新值=', newValue);
				console.log('==oldValue=旧值=', oldValue);
				if (newValue == '1') {
					this.goQianyue()
				}
			}
		},
		mounted() {
			this.getAppLoginAppid()
			console.log('当前的uid', getUserId());
			this.userId = getUserId()
			this.getPaymentList()
			this.wxOpenId = uni.getStorageSync('wxCodeOpenId')
			// #ifdef H5
			this.judgeBrowserEnv()
			// #endif
		},

		methods: {
			//判断是否需要支付宝去登录授权
			judgeIsHasUserId() {
				let userId = this.$getUid()
				this.$request(
					// `order/mall/liteUserOrders/getAliPayAuthorizeUserTwo?uid=${userId}&noCardState=${this.data.noCardState}`, {},
					`order/mall/liteUserOrders/getAliPayAuthorizeUserTwo?uid=${userId}&noCardState=4`, {},
					'get', false,
					true).then((res) => {
					if (res.businessSuccess || res.success) {
						this.isHasUserIdSta = res.data
					}
				});
			},
			//app支付宝登录获取appid传给支付宝
			getAppLoginAppid() {
				this.$request('member/mall/aliPay/user/getAppPlatFormAppId', {}, 'get', false, true).then((
					res) => {
					if (res.businessSuccess || res.success) {
						this.appLoginAppidStr = res.data
					}
				});
			},
			//判断当前浏览器环境
			judgeBrowserEnv() {
				let ua = navigator.userAgent.toLowerCase(); // 这里将所有字母转小写
				// let isWxBrowser = ua.indexOf('micromessenger') != -1
				// console.log('微信环境吗', ua.indexOf('micromessenger') != -1);
				if (ua.indexOf('micromessenger') !== -1) {
					this.isWxBrowser = true
					// this.getWechatCode()
				} else {
					this.isWxBrowser = false
				}
			},
			getWechatCode() {
				let appid = "wx49972ce22e3b2c47"; //微信APPid
				let code = this.getUrlCode().code; //是否存在code
				let local = window.location.href;
				if (code == null || code === "") {
					console.log('公众号不存在就打开上面的地址进行授权');
					//不存在就打开上面的地址进行授权
					window.location.href =
						"https://open.weixin.qq.com/connect/oauth2/authorize?appid=" +
						appid +
						"&redirect_uri=" +
						encodeURIComponent(local) +
						"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
				} else {
					this.code = code;
				}
			},
			getUrlCode() {
				// 截取url中的code方法
				var url = window.location.search;
				var theRequest = new Object();
				if (url.indexOf("?") != -1) {
					var str = url.substr(1);
					var strs = str.split("&");
					for (var i = 0; i < strs.length; i++) {
						theRequest[strs[i].split("=")[0]] = strs[i].split("=")[1];
					}
				}
				return theRequest;
			},
			//是否签约
			goSignVali() {
				this.$request('order/mall/liteUserOrders/signValidate', {
					orderId: this.order.orderId
				}, 'post', false).then((res) => {
					if (res.data == '1') {
						this.goQianyue()
					} else {
						uni.showToast({
							title: '订单异常返回false，请联系客服',
							icon: 'none',
							duration: 3000
						});
					}
				});
			},
			//动态获取用户的支付方式（hlb-合利宝，zfb-支付宝，wx-微信）
			getPaymentList() {
				this.$request('order/mall/components/getPayChannelList', {}, 'get', false).then((res) => {
					if (res.data && res.data.length > 0) {
						this.zfbHasPayment = res.data.some(item => item.type == 'zfb')
						this.wxHasPayment = res.data.some(item => item.type == 'wx')
					}
				});
			},
			//判断去支付或者去签约是否显示按钮
			judgeGopayOrQianyue() {
				//人脸识别-付合同费-付首付-签合同-签代扣-待发货
				let uidwei = getUserId()
				if (uidwei == 'bb4b6579bba261f027a098bb8bb57256765bffbept5s89glc5xg' && !this.order.payments) {
					// 1：，2：付合同费，3/4：正在生成合同，5：签合同，7：现在签署代扣
					// if (this.order.faceAuthStatus == '03' && !this.order.payments) 人连识别完成。首付已经完成
					if (this.order.status == '13' && (this.order.contractVerify == 2 || this.order.contractVerify == 3 ||
							this.order.contractVerify == 4 || this.order.contractVerify == 5 || this.order
							.contractVerify == 7 || this.order.contractVerify == 8)) {
						return true
					} else {
						return false
					}
				} else {
					return false
				}

			},
			tab_mengceng() {
				this.mengcengShow = false;
				this.tankuangShow = false;
			},
			//卡神扣支付合同费
			kashenkouPayment() {
				uni.showLoading({
					title: '支付加载中'
				});
				// #ifdef H5
				let payPlatform = 'H5'
				// #endif

				// #ifdef APP-PLUS
				let payPlatform = 'APP'
				// #endif
				this.$request('order/mall/liteUserOrders/kouPayContractCost', {
					orderId: this.order.orderId,
					payPlatform: payPlatform
				}, "POST").then(res => {
					if (res.success) {
						uni.hideLoading();
						// #ifdef H5
						window.location.href = res.result
						// #endif

						// #ifdef APP-PLUS
						uni.requestPayment({
							provider: 'alipay', //固定值为"alipay"
							orderInfo: res.result, //此处为服务器返回的订单信息字符串
							success: function(res) {
								console.log('支付成功');
								setTimeout(() => {
									uni.showToast({
										icon: 'none',
										title: '支付成功'
									});
									notifyTopPageRefresh.apply(this);
								}, 200); // 增加延时，避免后端接受支付宝回调不及时
							},
							fail: function(err) {
								uni.showToast({
									icon: 'none',
									title: '支付失败'
								});
								notifyTopPageRefresh.apply(this);
							}
						});
						// #endif
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.message || res.msg,
							icon: 'none',
							duration: 3000
						});
						// notifyTopPageRefresh.apply(this);
					}
				})
			},
			//先触发选择弹出窗和灰色蒙层  选择支付宝支付还是微信支付
			payHandler() {
				if (this.order.status == '13' && (this.order.contractVerify == 2 || this.order.contractVerify == 3 ||
						this.order.contractVerify == 4 || this.order.contractVerify == 5 || this.order.contractVerify ==
						7 || this.order.contractVerify == 8
					)) {
					let userId = getUserId()
					let userInfo = getZWZUserDetail()
					if (userId && !userInfo.telephone) {
						//有uid但是没有手机号，要去绑定手机号
						this.$onTo('/pagesOther/appLoginphone/appLoginphone')
						return
					}
					// let isNeedZfuLogin = getZfbUserIdSta()
					// if (isNeedZfuLogin) {
					// 	//支付宝已授权登录过
					// } else {
					// 	//授权询问弹窗打开
					// 	this.zfuLoginWinSta = true
					// }
					// 1下单就有：，2：付合同费，3/4：正在生成合同，5：签合同，7：现在签署代扣
					if (this.order.contractVerify == 2) {
						// 付签约费
						this.paySign()
					}
					if (this.order.contractVerify == 3 || this.order.contractVerify == 4) {
						uni.showToast({
							title: '合同正在生成中，请稍后刷新重试！',
							icon: 'none',
							duration: 3000
						});
						let timer1 = null
						timer1 = setTimeout(() => {
							notifyTopPageRefresh.apply(this);
							clearTimeout(timer1);
							timer1 = null
						}, 3000); // 延迟0.5秒
					}
					if (this.order.contractVerify == 5) {
						console.log('0-00');
						// 签合同，跳转的链接字段在订单列表数据中获取
						// #ifdef H5
						let isIosEnv = uni.getSystemInfoSync().platform
						if (isIosEnv == 'ios') {
							let timer2 = null
							timer2 = setTimeout(() => {
								window.open(this.order.signUrl, "_blank");
								clearTimeout(timer2);
								timer2 = null
							}, 10); // 延迟0.5秒
						} else {
							window.open(this.order.signUrl, "_blank");
						}
						// #endif

						// #ifdef APP-PLUS || APP
						plus.runtime.openURL(this.order.signUrl)
						// #endif

					}
					if (this.order.contractVerify == 7 || this.order.contractVerify == 8) {
						// 签代扣
						this.signWithhold()
					}
				}
			},
			//付签约费
			paySign() {
				uni.showLoading({
					title: '支付加载中'
				});
				// #ifdef H5
				let payPlatform = 'H5'
				// #endif

				// #ifdef APP-PLUS
				let payPlatform = 'APP'
				// #endif
				this.$request('order/mall/liteUserOrders/kouPayContractCost', {
					orderId: this.order.orderId,
					payPlatform: payPlatform,
					zfbUid: getUserId()
				}, "POST").then(res => {
					if (res.success) {
						uni.hideLoading();
						// #ifdef H5
						let isIosEnv = uni.getSystemInfoSync().platform
						if (isIosEnv == 'ios') {
							let timer1 = null
							timer1 = setTimeout(() => {
								window.open(res.result, "_blank");
								clearTimeout(timer1);
								timer1 = null
							}, 10); // 延迟0.5秒
						} else {
							window.open(res.result, "_blank");
						}
						// #endif

						// #ifdef APP-PLUS || APP
						plus.runtime.openURL(res.result)
						// #endif
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.message || res.msg,
							icon: 'none',
							duration: 3000
						});
					}
				})
			},
			//租机签代扣（签我们的爱扣宝）
			signWithhold() {
				uni.showLoading({
					title: '签约代扣加载中'
				});
				this.$request('order/mall/liteUserOrders/sdbSignCreate', {
					orderId: this.order.orderId,
				}, "POST").then(res => {
					uni.hideLoading();
					if (res.success) {
						// #ifdef H5
						let isIosEnv = uni.getSystemInfoSync().platform
						if (isIosEnv == 'ios') {
							let timer3 = null
							timer1 = setTimeout(() => {
								window.open(res.result, "_blank");
								clearTimeout(timer3);
								timer3 = null
							}, 10); // 延迟0.5秒
						} else {
							window.open(res.result, "_blank");
						}
						// #endif

						// #ifdef APP-PLUS || APP
						plus.runtime.openURL(res.result)
						// #endif
					} else {
						uni.showToast({
							title: res.message || res.msg,
							icon: 'none',
							duration: 3000
						});
					}
				})
			},








			//点击确定授权支付宝登录
			confirmZfbLogin() {
				// #ifdef H5
				let backUrl = 'https://mobile.zuji.fun/'
				let alipayUrl =
					`https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=${this.appLoginAppidStr}&scope=auth_user&redirect_uri=` +
					encodeURIComponent(backUrl) + '&state=init';
				let openURL = 'alipays://platformapi/startapp?appId=20000067&url=' + encodeURIComponent(alipayUrl);
				if (this.isWxBrowser) {
					//微信环境
					let weixinUrl = `https://ds.alipay.com/?scheme=${encodeURIComponent(openURL)}`
					window.location.href = weixinUrl
				} else {
					//非微信环境（浏览器环境）
					window.location.href = openURL
				}
				// #endif

				// #ifdef APP-PLUS
				const AlipayAuth = uni.requireNativePlugin("DHQ-AlipayAuth")
				let that = this
				AlipayAuth.login({
						appId: this.appLoginAppidStr, //你在支付宝平台申请的App ID，动态获取
						scheme: 'max' // 需要传到支付宝SDK的scheme,注意需要在manifest.json配置
					},
					(res) => {
						//客户端成功获取授权临时票据（code）,向业务服务器发起登录请求。
						let code = res.auth_code
						that.$request("member/mall/aliPay/user/alipayLogin", {
								authCode: code,
								source: '1',
							}, "POST")
							.then((res) => {
								console.log('支付宝授权登录后跳回app把code传给接口成功', res)
								if (res.data.uid) {
									saveUserId(res.data.uid);
								}
								let userNewObj = {}
								userNewObj.telephone = res.data.telephone || ''
								userNewObj.nickName = res.data.nickName || ''
								saveZWZUserDetail(userNewObj);

								if (!res.data.telephone) {
									this.$onTo('/pagesOther/appLoginphone/appLoginphone')
								}
							})
							.catch(res => {
								// console.log('支付宝授权登录后跳回app把code传给接口报错', res)
								uni.showToast({
									title: '授权登录失败，请联系客服稍后再试',
									icon: 'none',
									duration: 2000,
								});
							})
					})
				// #endif
			},
			cancelZfbLogin() {},
			closeMengceng() {
				this.isWexinOpenSecondSign = false
			},
			tab_zhifubao() {
				this.zhifubaoCheckedState = !this.zhifubaoCheckedState;
				this.weixinCheckedState = false;
				this.payType = 'alipays';
			},
			tab_weixin() {
				this.weixinCheckedState = !this.weixinCheckedState;
				this.zhifubaoCheckedState = false;
				this.payType = 'wechats';
			},

			btn_comfirm() {
				if (!this.zhifubaoCheckedState && !this.weixinCheckedState) {
					uni.showToast({
						icon: 'none',
						title: '请选择支付方式'
					});
					return;
				}
				this.mengcengShow = false;
				this.tankuangShow = false;
				this.payMoneyHandler();
			},

			//把签约的方法单独拿出来
			goQianyue() {
				//不等于01：即待签约的单子，下面走的是签约的流程
				if (this.order.esignStatus === 4) {
					uni.showToast({
						title: '已拒签，请联系客服处理',
						icon: 'none'
					});
					return;
				} else {
					//未拒签
					// #ifdef MP-WEIXIN
					uni.showToast({
						title: '下单已完成，请联系客服获取合同链接',
						icon: 'none'
					});

					// #endif

					// #ifndef MP-WEIXIN
					// 0  未签署  2  签署完成   e签宝已签署    4  已拒签
					console.log('签合同前期签签签签', this.order);
					if (this.order.esignUrl && this.order.esignStatus === 0) {
						//有e签宝且未签署
						go_EQian(this.order, {
							platformType: 'h5'
						}, true);
						return;
					}
					if (this.order.signUrl && this.order.esignStatus !== 2) {
						// 有蚂蚁链或者未签署完成
						if (this.order.signUrl.indexOf('alipays') === 0) {
							go_Myl(this.order, {
								platformType: 'alipays'
							}, true);
						} else {
							go_Myl(this.order, {
								platformType: 'h5'
							}, true);
						}
						return true;
					}
					// #endif
				}
			},
			/**
			 * 点击去支付按钮的时候触发
			 */
			payMoneyHandler() {
				// if (this.order.status != '01' && this.order.signState === false) {
				// 	// 
				// 	if (this.userId == '28e86b182e7fcba67a2c06dc5b85246cb2dd4773dp7tx9sd4xki' || this.userId ==
				// 		'428f61ae64ba25bb3b49aeb84799e39c4cea7588k0sbre03vtw9' || this.userId ==
				// 		'c79350173fca164bdceef0307815108c9d85fffftax7bkuysawc' || this.userId ==
				// 		'26858a8a29ddab43ee8f44550aba74733211f8aab8iu5rvqrvyw') {
				// 		this.goSignVali()
				// 	} else {
				// 		this.goQianyue()
				// 	}
				// }
				if (this.order.status == '01') {
					//01是待支付，走支付流程
					const orderId = this.order && this.order.orderId;
					//#ifdef MP-WEIXIN
					const platformType = 'wechat';
					// #endif

					// #ifdef APP-PLUS
					const platformType = 'app';
					// #endif

					// #ifdef H5
					const platformType = 'h5';

					// #endif

					// #ifdef MP-ALIPAY
					const platformType = 'alipay';
					// #endif

					const postObj = {
						orderId,
						platformType,
						payType: this.payType
					};
					const cnMap = {
						orderId: '订单ID',
						platformType: 'platformType',
						payType: '支付方式'
					};
					const {
						postData,
						pass
					} = this.$postDataGuard(postObj, cnMap);
					if (!pass) return;
					let url = 'order/mall/api/order/userFreezeAgain';
					const isJiesuan = checkOrderSettleNeedPay(this.order);
					if (isJiesuan) {
						let v;
						if (this.userOrderCashDto) v = this.userOrderCashDto.settlementRent;
						else v = this.order.settlementRent;
						postData.amount = v;
						url = 'order/mall/api/order/settlement/liteUserPaySettlement';
					}
					console.log('鑫app微信支付', url, postData);
					this.$request(url, postData, 'POST').then((res) => {
						console.log('3333333---33333', res);
						const resData = res.data || {};
						let data;
						if (isJiesuan) data = [resData.payUrl, true]; // 结算待支付时的支付
						else data = [resData.freezeAgainUrl];

						uni.showLoading({
							title: '加载中'
						});
						// #ifdef MP-WEIXIN
						if (res.data.freezeUrl == null && res.data.wechatOrderMap == null) {
							var that = this;
							uni.hideLoading();
							uni.showModal({
								title: '温馨提示',
								content: '订单已生成，请耐心等待平台审核!',
								success: function(res) {
									if (res.confirm) {
										that.partCoverCall();
										console.log('用户点击确定');
									} else if (res.cancel) {
										that.partCoverCall();
										console.log('用户点击取消');
									}
								}
							});
						} else if (res.data.wechatOrderMap) {
							var that = this;
							wx.requestPayment({
								timeStamp: res.data.wechatOrderMap.timeStamp, //时间戳
								nonceStr: res.data.wechatOrderMap.nonceStr, //随机字符串
								package: res.data.wechatOrderMap.package,
								signType: 'RSA', //签名算法
								paySign: res.data.wechatOrderMap.paySign, //签名
								success: function(res) {
									uni.hideLoading();
									setTimeout(() => {
										uni.showToast({
											icon: 'none',
											title: '支付成功'
										});
									}, 100); // 加入一点延时，避免后端接收支付宝回调不及时。若不需要，那去掉延时
									notifyTopPageRefresh.apply(this);
								},
								fail: function(err) {
									uni.hideLoading();
									console.log('支付失败');
									setTimeout(() => {
										uni.showToast({
											icon: 'none',
											title: '支付失败'
										});
									}, 100);
									notifyTopPageRefresh.apply(this);
								},
								complete: function(res) {
									uni.hideLoading();
									console.log('支付完成');
								}
							});
						}
						// #endif

						// 二、非微信（ (app zfb)  h5 ）小程序内走的方法
						// #ifndef MP-WEIXIN
						console.log('新app的返回结果', res);
						var that = this;
						if (!!res.data.freezeAgainUrl) {
							let useTradeSta = !res.data.serialNo ? true : false;
							// 2.1  (app zfb)内走的方法
							// #ifndef H5
							tradePay(...data, useTradeSta)
								.then((res) => {
									var that = this;
									if (res.resultCode === '9000') {
										uni.hideLoading();
										setTimeout(() => {
											uni.showToast({
												title: '支付成功'
											});
										}, 1000);
										notifyTopPageRefresh.apply(this);
									}
									if (res.resultCode === '6001') {
										uni.hideLoading();
										setTimeout(() => {
											uni.showToast({
												icon: 'none',
												title: '用户取消支付'
											});
										}, 1000);
										notifyTopPageRefresh.apply(this);
									}
									if (res.channel.serviceReady) {
										uni.hideLoading();
										setTimeout(() => {
											uni.showToast({
												title: '支付成功'
											});
										}, 1000);
										notifyTopPageRefresh.apply(this);
									}
								})
								.catch(() => {
									// 支付失败||取消支付
								});
							// #endif
							// #ifdef H5
							//h5支付宝支付走的
							window.location.href = res.data.freezeAgainUrl;
							// #endif
						} else {
							if (that.weixinCheckedState && res.data.wechatOrderMap.h5_url) {
								window.location.href = res.data.wechatOrderMap.h5_url;
							}
						}
						// #ifdef APP-PLUS
						console.log('进11111');
						// app的微信付款
						if (that.weixinCheckedState && res.data && res.data.wechatOrderMap) {
							console.log('进22222');
							console.log('==========weixinzhifu:', res);
							uni.requestPayment({
								provider: 'wxpay',
								orderInfo: {
									appid: res.data.wechatOrderMap
										.appid, // 微信开放平台 - 应用 - AppId，注意和微信小程序、公众号 AppId 可能不一致
									noncestr: res.data.wechatOrderMap.nonceStr, // 随机字符串
									package: res.data.wechatOrderMap.packageVal, // 固定值
									partnerid: res.data.wechatOrderMap.partnerId, // 微信支付商户号
									prepayid: res.data.wechatOrderMap.prepayId, // 统一下单订单号
									timestamp: res.data.wechatOrderMap.timestamp, // 时间戳（单位：秒）
									sign: res.data.wechatOrderMap.sign // 签名，这里用的 MD5/RSA 签名
								}, //此处为服务器返回的订单信息字符串
								success: function(res) {
									uni.hideLoading();
									setTimeout(() => {
										uni.showToast({
											icon: 'none',
											title: '支付成功'
										});
										notifyTopPageRefresh.apply(this);
									}, 1500);
								},
								fail: function(err) {
									console.log('支付失败:' + JSON.stringify(err));
									notifyTopPageRefresh.apply(this);
								}
							});
						}
						// #endif
						// #endif
					});
				}
			},
			danduWxCodePay() {
				let obj1 = {
					orderId: this.order.orderId,
					platformType: 'h5',
					payType: 'wechats',
					isWxBrowser: this.wxOpenId ? this.wxOpenId : this.code
				}
				this.$request('order/mall/api/order/userFreezeAgain', obj1, 'POST').then(res => {
					this.wxOfficialAccountPay(res.data.wechatOrderMap)
				})
			},
			//微信公众号支付
			wxOfficialAccountPay(wxPayObj) {
				if (typeof WeixinJSBridge == "undefined") {
					if (document.addEventListener) {
						document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
					} else if (document.attachEvent) {
						document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
						document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
					}
				} else {
					WeixinJSBridge.invoke(
						'getBrandWCPayRequest', {
							appId: wxPayObj.appId, // 公众号id     
							timeStamp: wxPayObj.timeStamp, // 时间戳     
							nonceStr: wxPayObj.nonceStr, // 随机串     
							package: wxPayObj.package, // 订单详情扩展字符串
							signType: 'RSA', // 微信签名方式    
							paySign: wxPayObj.paySign // 微信签名 
						},
						function(res) {
							if (res.err_msg == "get_brand_wcpay_request:ok") {
								console.log('微信公众号支付成功', );
								//res.err_msg将在用户支付成功后返回ok，这时调取你本身服务端业务查询，若已支付成功，则跳转成功页面，展示给用户。
								setTimeout(() => {
									uni.showToast({
										icon: 'none',
										title: '支付成功'
									});
									notifyTopPageRefresh.apply(this);
								}, 1500);
							} else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
								console.log('微信公众号支付取消', );
								// 取消支付;
								notifyTopPageRefresh.apply(this);
							} else if (res.err_msg === 'get_brand_wcpay_request:fail') {
								console.log('微信公众号支付失败', );
								// 支付失败;
								notifyTopPageRefresh.apply(this);
							}
						});
				}
			},
			partCoverCall() {
				notifyTopPageRefresh.apply(this);
			}
		}
	};
</script>

<style lang="less" scoped>
	.bigMengceng {
		display: flex;
		justify-content: flex-end;
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 100vh;
		z-index: 999999;
		background: rgba(76, 76, 76, 0.9);
	}

	.openImg {
		width: 240rpx;
		height: 160rpx;
		display: block;
		margin: 20rpx 30rpx 0 0;
	}

	.actionBtn {
		width: 138rpx;
		height: 56rpx;
		border-radius: 30rpx;
		border: 1px solid #c0c0c0;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
		margin-left: 24rpx;
		flex-shrink: 0;
		float: right;
		// position: absolute;
	}

	.actionBtn {
		position: relative;
	}

	.tankuang {
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 150;
		width: 100%;
		height: 600rpx;
		background-color: white;
	}

	.btn_bottom {
		width: 94%;
		letter-spacing: 10rpx;
		height: 80rpx;
		position: absolute;
		bottom: 50rpx;
		left: 50%;
		transform: translateX(-50%);
		border-radius: 10rpx;
		line-height: 80rpx;
		text-align: center;
		color: white;
		background-color: #1777ff;
	}

	.mengceng {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 100vh;
		z-index: 100;
		opacity: 0.5;
		/* background-color: #999999; */
		background-color: #4b2323;
	}
</style>